home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / vwfd.zip / VWFD.ASM < prev    next >
Assembly Source File  |  1992-03-17  |  6KB  |  243 lines

  1. PAGE 58,132
  2. ;******************************************************************************
  3. TITLE VWFD 
  4. ;******************************************************************************
  5. ;
  6. ;   (C) Copyright MICROSOFT Corp., 1990
  7. ;
  8. ;   Title:      VWFD.ASM 
  9. ;
  10. ;   Version:    3.00
  11. ;
  12. ;   Date:       15-Nov-1990 
  13. ;
  14. ;   Author:     Neil Sandlin
  15. ;
  16. ;
  17. ;------------------------------------------------------------------------------
  18. ;
  19. ;   Change log:
  20. ;
  21. ;      DATE     REV                 DESCRIPTION
  22. ;   ----------- --- -----------------------------------------------------------
  23. ;
  24. ;==============================================================================
  25.  
  26.         .386p
  27.  
  28. ;******************************************************************************
  29. ;                             I N C L U D E S
  30. ;******************************************************************************
  31.  
  32.         .XLIST
  33.         INCLUDE VMM.Inc
  34.         INCLUDE Debug.Inc
  35.         INCLUDE VDD.Inc
  36.         INCLUDE VWFD.Inc
  37.         .LIST
  38.  
  39.  
  40. VWFD_CB_DATA STRUC
  41.  
  42. VWFD_State  dd  ?
  43.  
  44. VWFD_CB_DATA ENDS
  45.  
  46.  
  47. ;******************************************************************************
  48. ;                V I R T U A L   D E V I C E   D E C L A R A T I O N
  49. ;******************************************************************************
  50.  
  51. Declare_Virtual_Device VWFD, 3, 0, VWFD_Control, VWFD_Dev_ID,, \
  52.                                     VWFD_API_PROC , VWFD_API_Proc
  53.  
  54.  
  55. ;******************************************************************************
  56. ;                         L O C A L   D A T A
  57. ;******************************************************************************
  58.  
  59. VxD_LOCKED_DATA_SEG
  60.         ALIGN   4
  61.  
  62. VWFD_CB_Offset  dd  0
  63. VDD_VMType_Proc dd  0
  64.  
  65. VxD_LOCKED_DATA_ENDS
  66.  
  67.  
  68. VxD_ICODE_SEG
  69.  
  70. ;******************************************************************************
  71. ;
  72. ;   VWFD_Sys_Crit_Init
  73. ;
  74. ;   DESCRIPTION:
  75. ;       This routine gets some "VM BLOCK" memory.
  76. ;   
  77. ;
  78. ;==============================================================================
  79.  
  80. BeginProc VWFD_Sys_Crit_Init
  81.  
  82.         push    ebx
  83.         VMMCall _Allocate_Device_CB_Area, <<SIZE VWFD_CB_DATA>, 0>
  84.         test    eax, eax
  85.         jnz     SHORT VWFD_CB_OK
  86.         Debug_Out "VWFD: Allocate_Device_CB_Area failed"
  87.         VMMCall Fatal_Memory_Error
  88.  
  89. VWFD_CB_OK:
  90.         mov     [VWFD_CB_Offset], eax
  91.         pop     ebx
  92.         
  93.         clc
  94.         ret
  95.  
  96.  
  97. EndProc VWFD_Sys_Crit_Init
  98.  
  99. ;******************************************************************************
  100. ;
  101. ;   VWFD_Device_Init
  102. ;
  103. ;   DESCRIPTION:
  104. ;       This routine hooks the service that specifies the windowed
  105. ;       state of a virtual machine.
  106. ;   
  107. ;
  108. ;==============================================================================
  109.  
  110. BeginProc VWFD_Device_Init
  111.  
  112.         mov     eax, VDD_Set_VMType         ; hook this service
  113.         mov     esi, OFFSET32 VWFD_Set_VMType ; with this little front end
  114.         VMMCall Hook_Device_Service         ; grab it
  115.         jc      SHORT not_hooked            ; huh?
  116.         mov     [VDD_VMType_Proc], esi
  117.   
  118. not_hooked:
  119.         clc
  120.         ret
  121.  
  122.  
  123. EndProc VWFD_Device_Init
  124.  
  125. VxD_ICODE_ENDS
  126.  
  127.  
  128.  
  129. ;******************************************************************************
  130.  
  131.  
  132. VxD_LOCKED_CODE_SEG
  133.  
  134. ;******************************************************************************
  135. ;
  136. ;   VWFD_Control
  137. ;
  138. ;   DESCRIPTION:
  139. ;
  140. ;       This is a call-back routine to handle the messages that are sent
  141. ;       to VxD's to control system operation. 
  142. ;
  143. ;
  144. ;==============================================================================
  145.  
  146. BeginProc VWFD_Control
  147.  
  148.         Control_Dispatch Sys_Critical_Init, VWFD_Sys_Crit_Init
  149.         Control_Dispatch Device_Init, VWFD_Device_Init
  150.         clc
  151.         ret
  152.  
  153. EndProc VWFD_Control
  154.  
  155. ;******************************************************************************
  156. ;
  157. ;   VWFD_Set_VMType
  158. ;
  159. ;   DESCRIPTION:
  160. ;       This routine keeps track of the windowed state of each VM.
  161. ;   
  162. ;
  163. ;==============================================================================
  164.  
  165. BeginProc VWFD_Set_VMType
  166.  
  167.         pushad
  168.         mov     esi, ebx                    ; vm block
  169.         add     esi, [VWFD_CB_Offset]       ; point to our area
  170.         mov     [esi.VWFD_State], eax       ; save the current state
  171.         popad
  172.         jmp     [VDD_VMType_Proc]           ; chain to real handler
  173.  
  174. EndProc VWFD_Set_VMType
  175.  
  176.  
  177. VxD_LOCKED_CODE_ENDS
  178.  
  179.  
  180. VxD_CODE_SEG
  181.  
  182. BeginDoc
  183. ;******************************************************************************
  184. ;
  185. ;   VWFD_API_Proc
  186. ;
  187. ;   DESCRIPTION:
  188. ;
  189. ;       This is the exported API procedure that is callable from VM's. 
  190. ;       An application needs only to use INT 2Fh, AX=1684h, BX=device ID
  191. ;       and a call back address is returned. Then, when the
  192. ;       address is called, eventually it ends up here. 
  193. ;
  194. ;   ENTRY:
  195. ;       ebp -> Client data area
  196. ;       ebx -> Current VMCB
  197. ;
  198. ;
  199. ;==============================================================================
  200. EndDoc
  201.  
  202. BeginProc VWFD_API_Proc
  203.  
  204.         push    ebx                             ; save ebx
  205.  
  206.         movzx   eax, WORD PTR [ebp.Client_BX]   ; Get requested VMID
  207.         or      eax, eax                        ; non-zero?
  208.         jz      short vmcb_ok                   ; zero, ebx is correct
  209. vmid_scan:
  210.         cmp     eax, [ebx.CB_VMID]              ; found it?
  211.         je      short vmcb_ok                   ; yes
  212.         VMMCall Get_Next_VM_Handle              ; get next
  213.         VMMCall Test_Cur_VM_Handle              ; back to start of list?
  214.         jne     vmid_scan                       ; no
  215.         jmp     short VWFD_API_Invalid         ; return carry
  216.  
  217. vmcb_ok:
  218.         mov     esi, ebx                        ; vm block
  219.         add     esi, [VWFD_CB_Offset]          ; point to our area
  220.         mov     edx, [esi.VWFD_State]          ; get the state
  221.  
  222.         and     [ebp.Client_Flags], NOT CF_Mask ; clear VM's carry flag
  223.  
  224.         mov     [ebp.Client_AX], dx             ;
  225.         shr     dx, 16
  226.         mov     [ebp.Client_DX], dx
  227.  
  228.         jmp     SHORT VWFD_exit
  229.  
  230. VWFD_API_Invalid:
  231.         or      [ebp.Client_Flags], CF_Mask
  232.  
  233. VWFD_exit:
  234.         pop     ebx                             ; restore ebx
  235.         ret
  236.  
  237. EndProc VWFD_API_Proc
  238.  
  239. VxD_CODE_ENDS
  240.  
  241.         END
  242. 
  243.